const mysql = require("mysql2");

// 创建连接池

const connection = mysql.createPool({
  host: "localhost",
  port: "3306",
  user: "root",
  password: "admin123",
  database: "music_db",
  connectionLimit: 5,
});

const statement = "SELECT * FROM `products` WHERE  price > 1000 AND score >7";

// connection.query(statement, (err, val) => {
//   console.log(val);
// });
connection.execute(statement, [1000, 7], (err, value) => {
  console.log(value);
});

// promise 操作

connection
  .promise()
  .execute(statement, [1000, 7])
  .then((res) => {
    console.log(res);
    const [value, files] = res;
    console.log(value);
  });
